package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import java.util.List;

import org.zhadoop.stream.cql.DriverContext;
import org.zhadoop.stream.cql.exception.CQLException;
import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.hooks.SemanticAnalyzeHook;
import org.zhadoop.stream.cql.semanticanalyzer.SemanticAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;
import org.zhadoop.stream.cql.tasks.Task;

/**
 * select 表达式的解析内容
 * 
 * @author zwd
 *
 */
public class SelectExpressionContext extends ParseContext {

	private ExpressionContext expression;

	private StreamAllColumnsContext allColumns;

	private SelectAliasContext alias;

	@Override
	public String toString() {
		if (expression != null) {

			if (alias != null) {
				return expression.toString() + " " + alias.toString();
			} else {
				return expression.toString();

			}
		}
		return allColumns.toString();
	}

	public StreamAllColumnsContext getAllColumns() {
		return allColumns;
	}

	public void setAllColumns(StreamAllColumnsContext allColumns) {
		this.allColumns = allColumns;
	}

	public SelectAliasContext getAlias() {
		return alias;
	}

	public void setAlias(SelectAliasContext alias) {
		this.alias = alias;
	}
	
	public ExpressionContext getExpression() {
		return expression;
	}

	public void setExpression(ExpressionContext expression) {
		this.expression = expression;
	}

	@Override
	public Task createTask(DriverContext driverContext, List<SemanticAnalyzeHook> analyzeHooks) throws CQLException {
		return null;
	}

	@Override
	public SemanticAnalyzer createAnalyzer() throws SemanticAnalyzerException {
		return null;
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		walkExpression(walker, alias);
		walkExpression(walker, allColumns);
		walkExpression(walker, expression);
	}

}
